package ch.trackedbean.server;

import java.rmi.*;
import java.util.*;
import ch.trackedbean.server.data.dom.*;
import ch.trackedbean.server.data.to.*;
import ch.trackedbean.validator.*;

/**
 * Interface of a servic like component.
 * 
 * @author hautle
 */
public interface Server extends Remote {
	/** The name of in the RMI register. */
	public static String NAME = Server.class.getName();

	/**
	 * Returns a list from {@link Dom} objects of the specified type.
	 * 
	 * @param <T> The type
	 * @param type The type to fetch
	 * @return A list with all objects from the given type
	 * @throws RemoteException
	 */
	public <T extends Dom> List<T> getDomObjects(Class<T> type) throws RemoteException;

	/**
	 * Returns a list with all persons
	 * 
	 * @return A list with all persons
	 * @throws RemoteException
	 */
	public List<PersonShort> getPersons() throws RemoteException;

	/**
	 * Returns the person with the given key.
	 * 
	 * @param key The person key
	 * @return The person with the given key
	 * @throws RemoteException
	 */
	public PersonTO getPerson(Integer key) throws RemoteException;

	/**
	 * Saves the given person.
	 * 
	 * @param person The person to save
	 * @throws RemoteException
	 * @throws ValidationException
	 */
	public void savePerson(PersonTO person) throws RemoteException, ValidationException;

	/**
	 * Fetches the value of a specified attribute from a denoted TO.
	 * 
	 * @param <T> The type
	 * @param type The type from which to
	 * @param key The key of the TO
	 * @param attribute The attribute to fetch
	 * @return The value of the attribute
	 * @throws RemoteException
	 */
	public <T> T fetchLazy(Class<? extends TO> type, Integer key, String attribute) throws RemoteException;
}
